using VSTalk.Engine.Core.XmppConnection;
using VSTalk.Engine.Core.XmppUtils;
using VSTalk.Model;

using agsXMPP;
using agsXMPP.protocol.iq.roster;

namespace VSTalk.Engine.Core.XmppCommunication.Services.ContactManager
{
    public class ContactManager : BaseCommunicationService, IContantManager
    {
        private RosterManager _rosterManager;

        public override void Initialize(IClientConnection connection)
        {
            base.Initialize(connection);
            _rosterManager = new RosterManager(Connection);
        }

        public void AddContact(IContactInfo contactInfo)
        {
            _rosterManager.AddRosterItem(new Jid(contactInfo.Name, contactInfo.Server, null));
        }

        public void RemoveContact(Interlocutor interlocutor)
        {
            _rosterManager.RemoveRosterItem(XmppIdConverter.Jid(interlocutor));
            Client.Contacts.Remove(interlocutor);
        }
    }
}